package com.ruoyi.system.controller.mine;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.Workinfo;
import com.ruoyi.system.service.IWorkinfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 工作信息表Controller
 *
 * @author ruoyi
 * @date 2023-10-13
 */
@RestController
@RequestMapping("/workinfo")
public class WorkinfoController extends BaseController
{
    @Autowired
    private IWorkinfoService workinfoService;

    /**
     * 查询工作信息表列表
     */
    @RequiresPermissions("mine:workinfo:list")
    @GetMapping("/list")
    public TableDataInfo list(Workinfo workinfo)
    {
        startPage();
        List<Workinfo> list = workinfoService.selectWorkinfoList(workinfo);
        return getDataTable(list);
    }

    /**
     * 导出工作信息表列表
     */
    @RequiresPermissions("mine:workinfo:export")
    @Log(title = "工作信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Workinfo workinfo)
    {
        List<Workinfo> list = workinfoService.selectWorkinfoList(workinfo);
        ExcelUtil<Workinfo> util = new ExcelUtil<Workinfo>(Workinfo.class);
        util.exportExcel(response, list, "工作信息表数据");
    }

    /**
     * 获取工作信息表详细信息
     */
    @RequiresPermissions("mine:workinfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(workinfoService.selectWorkinfoById(id));
    }

    /**
     * 新增工作信息表
     */
    @RequiresPermissions("mine:workinfo:add")
    @Log(title = "工作信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Workinfo workinfo)
    {
        return toAjax(workinfoService.insertWorkinfo(workinfo));
    }

    /**
     * 修改工作信息表
     */
    @RequiresPermissions("mine:workinfo:edit")
    @Log(title = "工作信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Workinfo workinfo)
    {
        return toAjax(workinfoService.updateWorkinfo(workinfo));
    }

    /**
     * 删除工作信息表
     */
    @RequiresPermissions("mine:workinfo:remove")
    @Log(title = "工作信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(workinfoService.deleteWorkinfoByIds(ids));
    }
}
